package com.nand.module.user.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nand.library.base.base.BaseActivity;
import com.nand.library.base.utils.SpUtils;
import com.nand.module.user.R;
import com.nand.module.user.bean.UserInfoBean;
import com.nand.module.user.utils.UserUtils;

public class UserInfoActivity extends BaseActivity {

    private TextView userName;
    private TextView userSex;
    private TextView userEmail;
    private TextView userNum;
    private TextView userNums;
    private TextView userPhone;
    private TextView userTime;
    private LinearLayout userLogin;
    private String account;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int initLayout() {
        return R.layout.activity_user_info;
    }

    @Override
    protected boolean isActionBar() {
        return true;
    }

    @Override
    protected void initView() {
        userName = findViewById(R.id.tv_user_name);
        userSex = findViewById(R.id.tv_user_sex);
        userEmail = findViewById(R.id.tv_user_email);
        userNum = findViewById(R.id.tv_user_number);
        userNums = findViewById(R.id.tv_user_numbers);
        userPhone = findViewById(R.id.tv_user_phone);
        userTime = findViewById(R.id.tv_user_time);
        userLogin = findViewById(R.id.ll_login);
        account = SpUtils.readString(this, "account", "");

        userLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(UserInfoActivity.this,LoginActivity.class));
                finish();
            }
        });

        UserInfoBean userInfo = UserUtils.getUserInfo(this);
        if (userInfo!=null){
            userName.setText(userInfo.userName);
            userSex.setText(account);
            userEmail.setText(userInfo.userEmail);
            userNum.setText(userInfo.userPost);
            userNums.setText(userInfo.departMentName);
            userPhone.setText(userInfo.userTele);
            userTime.setText(userInfo.userBoardDate);
        }
    }

    @Override
    protected void initData() {
        mActionBar().setCenterText("个人中心");


    }
}
